package com.wpf.hf.service.impl;

import com.wpf.hf.dao.UserMapper;
import com.wpf.hf.entity.Result;
import com.wpf.hf.entity.UserOrderVo;
import com.wpf.hf.feign.OrderFeign;
import com.wpf.hf.pojo.Order;
import com.wpf.hf.pojo.User;
import com.wpf.hf.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Autowired
    private OrderFeign orderFeign;
    /**
     * ⽤户的ID查询⽤户信息
     *
     * @param username
     * @return
     */
    @Override
    public UserOrderVo findUserById(String username) {
        User user = userMapper.findUser(username);
        Result<List<Order>> result = orderFeign.findOrderList(username);
        List<Order> orderList = result.getData();
        UserOrderVo userOrderVo = new UserOrderVo();
        userOrderVo.setUser(user);
        userOrderVo.setList(orderList);
        return userOrderVo;
    }
}
